package com.only4play.practice.report.core.service.impl;

import com.only4play.codegen.support.model.JsonObject;
import com.only4play.practice.report.core.component.UploadFactory;
import com.only4play.practice.report.core.component.UploadInterface;
import com.only4play.practice.report.core.model.UploadCarInParam;
import com.only4play.practice.report.core.model.enums.ReportPlatformType;
import com.only4play.practice.report.core.service.UploadCenterService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * @author mdy
 * * @date 2024/10/21
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class UploadCenterServiceImpl implements UploadCenterService {

    private final UploadFactory uploadFactory;

    @Override
    public JsonObject<Object> enableParkUpload(Integer reportPlatformType) {

        log.info("[UploadCenter] 上报配置id:{}",reportPlatformType);
        Optional<ReportPlatformType> optional = ReportPlatformType.of(reportPlatformType);
        if (!optional.isPresent()) {
            return JsonObject.fail("上报平台类型不存在");
        }
        UploadInterface uploadInterface = uploadFactory.getUpload(optional.get());
        return uploadInterface.enableReport(reportPlatformType);
    }

    @Override
    public JsonObject<Object> carInReport(UploadCarInParam param) {

        return null;
    }

    @Override
    public JsonObject<Object> disableParkUpload(Integer reportPlatformType) {
        return null;
    }


}
